<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>作业</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f0f0f0;
            margin: 0;
            padding: 0;
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
        }

        .container {
            background-color: #fff;
            padding: 20px;
            border-radius: 5px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
            text-align: center;
        }

        label {
            font-weight: bold;
        }

        input[type="text"] {
            padding: 5px;
            border: 1px solid #ccc;
            border-radius: 5px;
            margin-bottom: 10px;
        }

        input[type="button"], input[type="reset"] {
            background-color: #007BFF;
            color: #fff;
            border: none;
            padding: 10px 20px;
            cursor: pointer;
            font-size: 16px;
            border-radius: 5px;
            transition: background-color 0.3s ease;
        }

        input[type="button"]:hover, input[type="reset"]:hover {
            background-color: #0056b3;
        }

        #result {
            font-weight: bold;
        }
    </style>
    <script>
        function computing() {
            var n = document.getElementById("n").value;
            var sum = 0;
            var b = 1;
            for (var j = 1; j <= n; j++) {
                b *= j;
                sum += b;
            }
            document.getElementById("result").value = sum;
        }
    </script>
</head>
<body>
<div class="container">
    <h1>计算Σn!</h1>
    <form action="#" method="post">
        <label for="n">输入 n :</label>
        <input id="n" name="n" type="text"><br><br>
        <label for="result">计算Σn! :</label>
        <input id="result" readonly type="text"><br><br>
        <input onclick="computing()" type="button" value="计算">
        <input type="reset" value="重置">
    </form>
</div>
</body>
</html>
